package com.ruoyi.web.controller.datastatistics;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.datastatistics.domain.TerminalsFreeze;
import com.ruoyi.datastatistics.service.ITerminalsFreezeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 大冻结数据（设备维度）Controller
 * 
 * @author ruoyi
 * @date 2023-09-07
 */
@RestController
@RequestMapping("/datastatistics/freeze")
public class TerminalsFreezeController extends BaseController
{
    @Autowired
    private ITerminalsFreezeService terminalsFreezeService;

    /**
     * 查询大冻结数据（设备维度）列表
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:freeze:list')")
    @GetMapping("/list")
    public TableDataInfo list(TerminalsFreeze terminalsFreeze)
    {
        startPage();
        List<TerminalsFreeze> list = terminalsFreezeService.selectTerminalsFreezeList(terminalsFreeze);
        return getDataTable(list);
    }

    /**
     * 导出大冻结数据（设备维度）列表
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:freeze:export')")
    @Log(title = "大冻结数据（设备维度）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TerminalsFreeze terminalsFreeze)
    {
        List<TerminalsFreeze> list = terminalsFreezeService.selectTerminalsFreezeList(terminalsFreeze);
        ExcelUtil<TerminalsFreeze> util = new ExcelUtil<TerminalsFreeze>(TerminalsFreeze.class);
        util.exportExcel(response, list, "大冻结数据（设备维度）数据");
    }

    /**
     * 获取大冻结数据（设备维度）详细信息
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:freeze:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(terminalsFreezeService.selectTerminalsFreezeByID(ID));
    }

    /**
     * 新增大冻结数据（设备维度）
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:freeze:add')")
    @Log(title = "大冻结数据（设备维度）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TerminalsFreeze terminalsFreeze)
    {
        return toAjax(terminalsFreezeService.insertTerminalsFreeze(terminalsFreeze));
    }

    /**
     * 修改大冻结数据（设备维度）
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:freeze:edit')")
    @Log(title = "大冻结数据（设备维度）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TerminalsFreeze terminalsFreeze)
    {
        return toAjax(terminalsFreezeService.updateTerminalsFreeze(terminalsFreeze));
    }

    /**
     * 删除大冻结数据（设备维度）
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:freeze:remove')")
    @Log(title = "大冻结数据（设备维度）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(terminalsFreezeService.deleteTerminalsFreezeByIDs(IDs));
    }
}
